/**
 *  FPUHelper.java : IceBird project
 *  17:25:18 
 */
package icebird.compiler.x86.old;

import icebird.compiler.x86.old.X86Register.FPU;

/**
 * @author Sergey Shulepoff[Knott]
 */
public final class FPUHelper {
	
	// Dont allow creation.
	private FPUHelper() {
	}
	
	public static final void fxch(X86Assembler asm, FPUStack f, Item i) {
		if (f.getPeek() != i) {
			FPU fpu = f.getRegister(i);
			fxch(asm, f, fpu);
		}
	}
	
	public static final void fxch(X86Assembler asm, FPUStack f, FPU reg) {
		if (reg == FPU.ST0) {
			throw new RuntimeException("Cannot fxch ST0");
		}
		
		asm.fxch(reg);
		f.fxch(reg);
	}
}
